var e, a, t, r, n, o = require("../../@babel/runtime/helpers/interopRequireDefault"), i = require("../../@babel/runtime/helpers/defineProperty"), s = o(require("../../@babel/runtime/regenerator")), c = require("../../@babel/runtime/helpers/asyncToGenerator"), l = o(require("../../utils/api")), d = getApp();

Page((i(e = {
    data: {
        statusBarHeight: d.globalData.statusBarHeight,
        resourceUrl: d.globalData.resourceUrl,
        name: "",
        headImg: "",
        rankImg: "",
        companyName: "",
        companyId: "",
        phone: "",
        score: "",
        restMemberScore: "",
        modifying: !1,
        focus: !0,
        list: [ {
            bind: "toSignRecord",
            image: "/images/daka.png",
            title: "打卡记录"
        }, {
            bind: "toAnswerRecord",
            image: "/images/answer-fill.png",
            title: "答题记录"
        }, {
            bind: "toRankRecord",
            image: "/images/rank-fill.png",
            title: "排名记录"
        }, {
            bind: "toScoreRecord",
            image: "/images/jfjl.png",
            title: "金币记录"
        }, {
            bind: "toMyCard",
            image: "/images/card.png",
            title: "我的卡片"
        }, {
            bind: "toMyMessage",
            image: "/images/wdxx.png",
            title: "我的消息"
        }, {
            bind: "toMyReward",
            image: "/images/lw.png",
            title: "我的奖励"
        }, {
            bind: "toReadList",
            image: "/images/qtyd.png",
            title: "青听悦读"
        }, {
            bind: "toMyQuestion",
            image: "/images/wdwt.png",
            title: "我的问题"
        } ],
        partyBranchList: [],
        partyBranchName: "",
        index: 0,
        signDays: 0,
        cardSum: null
    },
    onLoad: (n = c(s.default.mark(function e() {
        var a, t;
        return s.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                return a = wx.getStorageSync("openid"), e.prev = 1, e.next = 4, l.default.partyBranchList({
                    openid: a,
                    branchId: 1
                });

              case 4:
                t = e.sent, this.setData({
                    partyBranchList: t.result[0].children
                }), e.next = 11;
                break;

              case 8:
                e.prev = 8, e.t0 = e.catch(1), console.log(e.t0.msg);

              case 11:
              case "end":
                return e.stop();
            }
        }, e, this, [ [ 1, 8 ] ]);
    })), function() {
        return n.apply(this, arguments);
    }),
    onShow: function() {
        this.setData({
            name: d.globalData.userInfo.name,
            headImg: d.globalData.userInfo.headImg,
            rankImg: d.globalData.userInfo.rankImg,
            companyName: d.globalData.userInfo.companyName,
            companyId: d.globalData.userInfo.companyId,
            isParty: d.globalData.userInfo.isParty,
            phone: d.globalData.userInfo.phone,
            score: d.globalData.scoreboard,
            restMemberScore: d.globalData.restMemberScore,
            partyBranchName: d.globalData.userInfo.partyBranchName
        }), this.getSignList(), this.getCardInfo();
    },
    toMyCoin: function() {
        wx.navigateTo({
            url: "/home/pages/scoreRecord/scoreRecord"
        });
    },
    toMyCard: function() {
        wx.navigateTo({
            url: "/home/pages/cardRecord/cardRecord"
        });
    },
    getSignList: (r = c(s.default.mark(function e() {
        var a, t;
        return s.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                return a = wx.getStorageSync("openid"), e.prev = 1, e.next = 4, l.default.signList({
                    openid: a
                });

              case 4:
                t = e.sent, this.setData({
                    signDays: t.result.signDays
                }), e.next = 11;
                break;

              case 8:
                e.prev = 8, e.t0 = e.catch(1), console.log(e.t0);

              case 11:
              case "end":
                return e.stop();
            }
        }, e, this, [ [ 1, 8 ] ]);
    })), function() {
        return r.apply(this, arguments);
    }),
    getCardInfo: function() {
        var e = this;
        return c(s.default.mark(function a() {
            var t, r, n;
            return s.default.wrap(function(a) {
                for (;;) switch (a.prev = a.next) {
                  case 0:
                    return t = wx.getStorageSync("openid"), a.prev = 1, a.next = 4, l.default.getCardDetail({
                        openid: t
                    });

                  case 4:
                    r = a.sent, n = r.result, e.setData({
                        cardSum: n
                    }), a.next = 12;
                    break;

                  case 9:
                    a.prev = 9, a.t0 = a.catch(1), console.log(a.t0.msg);

                  case 12:
                  case "end":
                    return a.stop();
                }
            }, a, null, [ [ 1, 9 ] ]);
        }))();
    },
    modifyName: function() {
        this.setData({
            modifying: !0
        });
    },
    handleBlur: (t = c(s.default.mark(function e(a) {
        var t;
        return s.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                return t = wx.getStorageSync("openid"), e.prev = 1, e.next = 4, l.default.member({
                    openid: t,
                    name: a.detail.value
                });

              case 4:
                this.setData({
                    name: a.detail.value,
                    focus: !1,
                    modifying: !1
                }), d.globalData.userInfo.name = a.detail.value, e.next = 11;
                break;

              case 8:
                e.prev = 8, e.t0 = e.catch(1), console.log(e.t0.msg);

              case 11:
              case "end":
                return e.stop();
            }
        }, e, this, [ [ 1, 8 ] ]);
    })), function(e) {
        return t.apply(this, arguments);
    }),
    toSignRecord: function() {
        wx.navigateTo({
            url: "/profile/pages/signRecord/signRecord"
        });
    },
    toAnswerRecord: function() {
        wx.navigateTo({
            url: "/profile/pages/answerRecord/answerRecord"
        });
    },
    toRankRecord: function() {
        wx.navigateTo({
            url: "/profile/pages/rankRecord/rankRecord"
        });
    },
    toScoreRecord: function() {
        wx.navigateTo({
            url: "/home/pages/scoreRecord/scoreRecord"
        });
    }
}, "toMyCard", function() {
    wx.navigateTo({
        url: "/home/pages/cardRecord/cardRecord"
    });
}), i(e, "toMyMessage", function() {}), i(e, "toMyReward", function() {
    wx.navigateTo({
        url: "/profile/pages/myReward/myReward"
    });
}), i(e, "toReadList", function() {
    wx.navigateTo({
        url: "/profile/pages/readList/readList"
    });
}), i(e, "toMyQuestion", function() {
    wx.navigateTo({
        url: "/profile/pages/myQuestion/myQuestion"
    });
}), i(e, "pickerChange", (a = c(s.default.mark(function e(a) {
    var t;
    return s.default.wrap(function(e) {
        for (;;) switch (e.prev = e.next) {
          case 0:
            return t = wx.getStorageSync("openid"), e.prev = 1, e.next = 4, l.default.updatePartyBranch({
                openid: t,
                partyBranchId: this.data.partyBranchList[a.detail.value].id,
                companyId: this.data.companyId,
                isParty: this.data.isParty
            });

          case 4:
            this.setData({
                index: a.detail.value,
                partyBranchName: this.data.partyBranchList[a.detail.value].name
            }), e.next = 10;
            break;

          case 7:
            e.prev = 7, e.t0 = e.catch(1), console.log(e.t0.msg);

          case 10:
          case "end":
            return e.stop();
        }
    }, e, this, [ [ 1, 7 ] ]);
})), function(e) {
    return a.apply(this, arguments);
})), e));